#from lcd12864 import print8
import utime
from machine import ADC,Pin,I2C
SHT31_address       =   68

def sht31m(i2c):
    i2c.writeto(SHT31_address,b"\x2c\x06")

def sht31r(i2c):
    raw=i2c.readfrom(SHT31_address,6)
    (t,h)=(raw[0] << 8) + raw[1], (raw[3] << 8) + raw[4]
    temp = -45 + (175 * (t / 65535))
    return temp, 100 * (h / 65535)
if __name__=="__main__":
    import lc
    i2c = I2C(0,scl=Pin(lc.scl), sda=Pin(lc.sda), freq=400000)
    print(i2c.scan())
    sht31m(i2c)
    utime.sleep_ms(50)
    (t,h)=(sht31r(i2c))

    while 1 :
        sht31m(i2c)
        utime.sleep_ms(20)
        (t,h)=(sht31r(i2c))

        print(t,h)
        utime.sleep(1)